package com.vcredit.creditcat.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vcredit.creditcat.framework.pagination.Criteria;
import com.vcredit.creditcat.framework.pagination.Page;
import com.vcredit.creditcat.persistence.base.CountMapper;
import com.vcredit.creditcat.vo.ChanneManVo;

/**
 *
 * @author liaoshengjun
 *
 */
@Service
public class ChannelCountService {
	@Autowired
	private CountMapper countMapper;

	/**
	 * 根据不同的条件查询不同数据 1. 总数据 2. 分组数据
	 *
	 * @param request
	 * @param groupBy
	 * @return
	 */
	public List<ChanneManVo> findByTime(HttpServletRequest request, String groupBy) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", request.getParameter("startTime"));
		map.put("endTime", request.getParameter("endTime"));
		map.put("groupByTime", groupBy);
		List<ChanneManVo> chioList = countMapper.find(map);
		return chioList;
	}

	public Page<ChanneManVo> findByPage(Criteria criteria) throws Exception {
		List<ChanneManVo> mpo =countMapper.findByPage(criteria);
		Long li =countMapper.findByPageCount(criteria);
		criteria.toString().split(";");
		return new Page<ChanneManVo>(li,mpo );
	}
	public Long findByPageCount(Criteria criteria) {
		return null;

	}
}
